//
//  YXTopicHeaderView.m
//  CreditCard
//
//  Created by 杨旭 on 2018/1/31.
//  Copyright © 2018年 杨旭. All rights reserved.
//

#import "YXTopicHeaderView.h"
#import "YXPostModel.h"
#import "YXTopicModel.h"
@interface YXTopicHeaderView ()

@property (weak, nonatomic) IBOutlet UIImageView *picImageView;
@property (weak, nonatomic) IBOutlet UILabel *nameLab;
@property (weak, nonatomic) IBOutlet UILabel *timeLab;
@property (weak, nonatomic) IBOutlet UIButton *replyBtn;
@property (weak, nonatomic) IBOutlet UIButton *likeBtn;
@property (weak, nonatomic) IBOutlet UILabel *titleLab;

@end


@implementation YXTopicHeaderView

-(instancetype)initWithFrame:(CGRect)frame {
    
    if (self = [super initWithFrame:frame]) {
        // 从xib中找到我们定义的view
        NSArray *viewArray = [[NSBundle mainBundle]loadNibNamed:@"YXTopicHeaderView" owner:self options:nil];
        self = viewArray[0];
        self.frame = frame;
    }
    return self;
    
}

- (void)setModel:(YXTopicModel *)model {
    _model = model;
    [_likeBtn setTitle:_model.collerCount forState:(UIControlStateNormal)];
    [_replyBtn setTitle:_model.postReplyCount forState:(UIControlStateNormal)];
}

- (void)setPostModel:(YXPostModel *)postModel {
    _postModel = postModel;
    _titleLab.text = [NSString stringWithFormat:@"%@",_postModel.title];
    [_picImageView sd_setImageWithURL:[NSURL URLWithString:_postModel.portraitImgUrl] placeholderImage:[UIImage imageNamed:@""]];
    _nameLab.text = _postModel.nickname;
    _timeLab.text = [UILabel formateData:_postModel.createTime];
}


@end
